/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mintandleaf.webkits.validator;

/**
 *
 * @author teguhh
 */
public class RegularExpresionValidator extends BaseValidator{

    private String regex;

    public String getRegex() {
        return regex;
    }

    public void setRegex(String regex) {
        this.regex = regex;
    }

    public RegularExpresionValidator(){
        setErrorMessage("Value did't match");
    }

    public RegularExpresionValidator(String paramRegex,String paramErrorMessage){
        setRegex(paramRegex);
        setErrorMessage(paramErrorMessage);
    }

    public RegularExpresionValidator(String paramRegex){
        setRegex(paramRegex);
        setErrorMessage("Value did't match");
    }
    /**
     * Validate the object value with the regex expression
     * if the regex expresion is null this method always return
     * true
     * @param value object tobe validate
     * @return true / false on validation
     */
    @Override
    public boolean validate(Object value) {
        if(getRegex()!=null){
            
            return false;
        }else
            return true;
    }

}
